#ifndef EVENTCREATOR_HPP_
#define EVENTCREATOR_HPP_

#include <vector>
#include "kit/event/Event.hpp"
#include "kit/message/Message.hpp"

namespace KitEvent
{
	/**
	 * The purpose of this class is to hide the way the events are created
	 * according to the currently processed message. The idea bases on the chain
	 * of responsibility, where every subscribed event is asked if it's able to
	 * handle incoming message. If the event says yes, then we make copy of him
	 * and use the copy to process the message. Otherwise we keep asking as long
	 * as we find the proper event, or finish the list of registered events.
	 */
    class EventCreator
    {
    public:
    	/**
    	 * In the constructor we are registering events that we want to handle by
    	 * adding them to our chain.
    	 */
        EventCreator();
        /**
         * In the destructor we clean the events we added in the constructor.
         */
        ~EventCreator();

        /**
         * Process events in the chain and ask each one if he is able to handle the
         * iMessage. If one says yes, then make a copy of him and return, otherwise keep
         * asking.
         *
         * \param iMessage message that should be handled.
         * \return Event serving iMessage, or NULL if no event found.
         */
        Event * createEvent(KitMessage::Message * iMessage);

    private:
        std::vector <Event *> _eventChain;
    };
}

#endif // EVENTCREATOR_HPP
